# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ropeme
pkgver=4.9b3a8fd
pkgrel=4
groups=('blackarch' 'blackarch-exploitation')
pkgdesc='A set of python scripts to generate ROP gadgets and payload.'
arch=('any')
url='http://www.vnsecurity.net/2010/08/ropeme-rop-exploit-made-easy/'
license=('GPL')
depends=('python2' 'python2-distorm')
makedepends=('git')
source=("git+https://github.com/packz/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  chmod +x "$pkgdir/usr/share/$pkgname/exploit.py"
  chmod +x "$pkgdir/usr/share/$pkgname/$pkgname/readelf.py"
  chmod +x "$pkgdir/usr/share/$pkgname/$pkgname/search-gadgets.py"
  chmod +x "$pkgdir/usr/share/$pkgname/$pkgname/ropshell.py"

  ln -s "/usr/share/$pkgname/$pkgname/ropshell.py" \
    "$pkgdir/usr/bin/ropeme-ropshell"
  ln -s "/usr/share/$pkgname/$pkgname/readelf.py" \
    "$pkgdir/usr/bin/ropeme-readelf"
  ln -s "/usr/share/$pkgname/$pkgname/search-gadgets.py" \
    "$pkgdir/usr/bin/ropeme-search-gadgets"
  ln -s "/usr/share/$pkgname/exploit.py" "$pkgdir/usr/bin/ropeme-exploit"
}

